package com.cxmx.escort.runner;

import com.cxmx.escort.common.redis.CacheUtils;
import lombok.extern.log4j.Log4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author chenyunxuan
 */
@Component
@Log4j
public class ScheduledTasks {


    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");


    /**
     * 每天零点消灭订单计数
     */
    @Scheduled(cron = "0 58 23 * * ?")
    public void delDay() {
        //删除一天的订单状态
        log.info("delele start");
        long k = CacheUtils.deleteAllKey(LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYYMMdd")) + ":");
        log.info("delete " + k + "=keys");
    }
}